$(function() {

	/* Custom SrollBar in Categories List */
	if($(".scroll-panel").length) {
		$('.scroll-panel').jScrollPane({
			verticalDragMinHeight : 59,
			verticalDragMaxHeight : 59
		});
	}

	// If Home Page Slider Exists
	if($("div#home-slider").length) {
		$("div#home-slider ul").anythingSlider({
			hashTags : false,
			expand : true,
			buildArrows : false,
			autoPlay : false,
			buildStartStop : false,
			infiniteSlides : false,
			navigationFormatter : function(index, panel) {
				return index;
				// This would have each tab with the text 'Panel #X' where X = index
			}
		});

	}

	// If Home Page Has Categories
	if($("div#home-categories-inner").length) {

		$("div#home-categories-inner").anythingSlider({
			hashTags : false,
			expand : true,
			showMultiple : 5,
			buildNavigation : false,
			buildArrows : false,
			autoPlay : false,
			buildStartStop : false,
			infiniteSlides : false,
			stopAtEnd : true
		});

		$("div#home-slider-arrows a#prev-btn").click(function() {
			$('div#home-categories-inner').data('AnythingSlider').goBack();
			return false;
		});

		$("div#home-slider-arrows a#next-btn").click(function() {
			$('div#home-categories-inner').data('AnythingSlider').goForward();
			return false;
		});
	}

	// Choose Categories Button
	$("a#choose-categories-btn").click(function() {
		$("div#choose-category-list").slideToggle();
		return false;
	});

	if($.browser.msie && parseInt($.browser.version, 10) == 7) {
		$("#choose-category-list a").css('width', $("#choose-category-list").width());
	}

	// Product Content Tabs
	$("#content-tabs ul li a").click(function() {

		$(this).parent().addClass('active');
		// add active class on clicked tab
		$(this).parent().siblings().removeClass('active');
		// remove active class from other tabs
		$(".product-content").hide();
		// hide all tab contents
		$($(this).attr('href')).show();
		// show clicked tab content

		return false;
	});

	// Comments Button
	$("a#comments-btn").click(function() {

		var btn = $(this);
		if(btn.hasClass('opened')) {
			btn.removeClass('opened').addClass('closed');
			$("#comments").slideUp();
		} else if(btn.hasClass('closed')) {
			btn.removeClass('closed').addClass('opened');
			$("#comments").slideDown();
		}

		return false;
	});

});
